package com.example.forestmanagement;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import org.greenrobot.eventbus.EventBus;


public abstract class BaseActivity extends AppCompatActivity {
    private final String TAG = getClass().getSimpleName();
    //是否注册eventBus
    public Boolean isRegisterEventBus = false;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        isRegisterEventBus = (isRegisterEventBus() != null && isRegisterEventBus());
        if (isRegisterEventBus) {
            EventBus.getDefault().register(this);
        }
    }

    protected abstract Boolean isRegisterEventBus();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (isRegisterEventBus) {
            EventBus.getDefault().unregister(this);
        }
    }
}